package com.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadD0 {

	static int i = 0;
	static boolean stop = false;

	public static void main(String[] args) {

		 executor();

	}

	private static void executor() {
		final ExecutorService executorService = Executors
				.newSingleThreadExecutor();
		executorService.execute(new Runnable() {
			@Override
			public void run() {

				while (!stop) {
					System.out.println(i++);
					System.out.println(executorService.isShutdown());
					if (i == 1000) {
						stop = true;
						executorService.shutdown();
						System.out.println(executorService.isShutdown());
						System.out.println("shutdown");
					}
				}

			}
		});

	}

}
